const express = require("express");
const router = express.Router();
const DictionaryModule = require("../../../api/dictionary");
const { DictionaryList,DictionaryValueList,EmptyDictionaryValue } = require("../../../api/dictionary");
router.post("/newPost", (req, res) => {
  DictionaryModule.AddDictionary(req)
    .then((r) => res.send(r))
    .catch((e) => res.send(e));
});
// 字典树
router.get("/treeList", (req, res) => {
  // treeModule(req.query)
  //   .then((r) => res.send(r))
  //   .catch((e) => res.send(e));
});
// 字典列表
router.get("/dictionaryList", (req, res) => {
  DictionaryList(req)
    .then((r) => res.send(r))
    .catch((e) => res.send(e));
});
// 添加字典
router.post("/addDictionary", (req, res) => {
  addDictionaryModule(req.body)
    .then((r) => res.send(r))
    .catch((e) => res.send(e));
});
// 删除字典
router.post("/RemoveDictionary", (req, res) => {
  RemoveDictionaryModule(req.body)
    .then((r) => res.send(r))
    .catch((e) => res.send(e));
});
// 修改字典
router.post("/updateDictionary", (req, res) => {
  updateDictionaryModule(req.body)
    .then((r) => res.send(r))
    .catch((e) => res.send(e));
});
// 字典内容列表
router.get("/dictionaryValueList", (req, res) => {
  DictionaryValueList(req)
    .then((r) => res.send(r))
    .catch((e) => res.send(e));
});
// 字典内容删除
router.post("/RemoveDictionaryValue", (req, res) => {
  RemoveDictionaryValueModule(req.body)
    .then((r) => res.send(r))
    .catch((e) => res.send(e));
});
// 字典内容修改
router.post("/updateDictionaryValue", (req, res) => {
  updateDictionaryValueModule(req.body)
    .then((r) => res.send(r))
    .catch((e) => res.send(e));
});
// 字典内容新增
router.post("/addDictionaryValue", (req, res) => {
  addDictionaryValueModule(req.body)
    .then((r) => res.send(r))
    .catch((e) => res.send(e));
});
// 清空字典内容
router.post("/EmptyDictionaryValue", (req, res) => {
  EmptyDictionaryValue(req)
    .then((r) => res.send(r))
    .catch((e) => res.send(e));
});

module.exports = router;
